package com.zlf.builder_schema.meal;

import com.zlf.builder_schema.ut.Item;

import java.util.ArrayList;
import java.util.List;
/**
 * <p>Project: bee-projects</p>
 * <p>Title: EduCourseNoteBean.java</p>
 * <p>Description:   </p>
 * <p>Copyright: Copyright (c) 2016 </p>
 * <p>Company: 华炜云商科技有限公司 www.hwtech.cc</p>
 *
 * @author Administrator
 * @version 1.0
 * @date 2017/2/9 10:16
 *
 * 套餐操作者
 *
 */
public class Meal {
    private List<Item> items = new ArrayList<Item>();

    /**
     * 添加套餐
     *
     * @param item
     */
    public void addItem(Item item){
        items.add(item);
    }

    /**
     * 计算价格
     *
     * @return
     */
    public float getCost(){
        float cost = 0.0f;

        for (Item item : items) {
            cost += item.price();
        }
        return cost;
    }

    /**
     * 显示套餐详情
     */
    public void showItems(){

        for (Item item : items) {
            System.out.print("Item : " + item.name());
            System.out.print(", Packing : " + item.packing().pack());
            System.out.println(", Price : " + item.price());
        }
    }
}
